<?php 
if(!isset($_SESSION)) 
{ 
	session_start(); 
}
$lang = $_SESSION['lang'];
if (empty($lang) || $lang == "EN") {
	include "../../value/value_en.php";
} else if($lang == "VN") {
	include "../../value/value_vn.php";
}
else {
	include "../../value/value_kr.php";
}
$_SESSION['thongbao_chamcong']="";

if(isset($_REQUEST['dfrom']) && isset($_REQUEST['dto']) && isset($_REQUEST['dname'])){
	if($_REQUEST['dfrom']!="" && $_REQUEST['dto']!="" && $_REQUEST['dname']!=""){
		set_time_limit( 0 );
		$dfrom=$_REQUEST['dfrom'];
		$dto=$_REQUEST['dto'];
		$nguoiguidi=$_SESSION['fullname'];
		$dname=$_REQUEST['dname'];
		
		$addressbrowser = $_SERVER['SERVER_NAME'];
		$temp = explode(".", $addressbrowser);
		$lang=$_SESSION['lang'];
		if($lang==''){
			$lang='EN';
			$_SESSION['lang']="EN";
		}
		
		$url = 'http://175.126.145.85/mail/mailchamcong.php';
		$fields = array(
								'lang' => urlencode($lang),
								'dfrom' => urlencode($dfrom),
								'dto' => urlencode($dto),
								'dname' => urlencode($dname),
								'company' => urlencode($temp[0]),
								'nguoiguidi' => urlencode($nguoiguidi)
						);
		/*$url = 'http://localhost/mail/mailchamcong.php';
		$fields = array(
								'lang' => urlencode($lang),
								'dfrom' => urlencode($dfrom),
								'dto' => urlencode($dto),
								'dname' => urlencode($dname),
								'company' => urlencode("elitech"),
								'nguoiguidi' => urlencode($nguoiguidi)
						);*/

		//url-ify the data for the POST
		foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
		rtrim($fields_string, '&');
		
		//open connection
		$ch = curl_init();
		
		//set the url, number of POST vars, POST data
		curl_setopt($ch,CURLOPT_URL, $url);
		curl_setopt($ch,CURLOPT_POST, count($fields));
		curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
		
		//execute post
		$result = curl_exec($ch);
		//echo $ch;
		//close connection
		curl_close($ch);
		$_SESSION['thongbao_chamcong']=$l_sending_mail_has_been_made;
	}
}
?>
	<input type="hidden" id="viewthongbao" name="viewthongbao" value="<?php echo $_SESSION['thongbao_chamcong'];?>" />
